package com.service.impl;


import com.dao.user.UserMapper;
import com.entity.User;
import com.service.user.UserService;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional
@Scope("prototype")
@Service("userService")
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    public List<User> findUserWithConditions(User user) {
        try{
            return  userMapper.getUserList(user);
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
    }
    public UserMapper getUserMapper(){
        return userMapper;
    }
    public void setUsetMapper(UserMapper userMapper){
        this.userMapper = userMapper;
    }

    @Transactional(propagation = Propagation.SUPPORTS)
    public List<User> findUsersWithConditions(User user) {
        return null;
    }

    @Override
    public int add(User user) {
        return 0;
    }

    @Override
    public boolean addNewUser(User user) {
        boolean result =false;
        try{
            if(userMapper.add(user)==1){
                result =true;
            }
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
        return result;
    }
}
